package tech.mhuang.ext.jwt.springboot.sample;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import tech.mhuang.ext.jwt.admin.JwtFramework;
import tech.mhuang.ext.jwt.admin.external.IJwtProducer;
import tech.mhuang.ext.spring.start.SpringContextHolder;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component
public class TestCreateJwt implements ApplicationRunner {

    @Autowired
    private JwtFramework jwtFramework;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("userId","1");
        //获取指定启动的bean-map key张三
        String token = jwtFramework.getProducer("zhangsan").create(map);
        log.info("{}",map);
        Map map2 = jwtFramework.getProducer("zhangsan").parse(token);
        String refreshToken = jwtFramework.getProducer("zhangsan").refresh(map2);
        log.info("{}",map2);
    }
}
